﻿<UserControl 
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"  
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:sw="clr-namespace:System.Windows;assembly=System.Windows.Controls"
	mc:Ignorable="d"
	x:Class="DemoNYTimes.CommunityComments"
	d:DesignWidth="640" d:DesignHeight="480" xmlns:NYTimes="clr-namespace:NYTimes;assembly=NYTimesSilverlightKit" FontFamily="Times New Roman" FontSize="14">

	<UserControl.Resources>
		<NYTimes:CommunityRecentComments x:Key="CommunityRecentCommentsDS" d:IsDataSource="True"/>
        <sw:HierarchicalDataTemplate x:Key="CommentTemplate" ItemsSource="{Binding Replies}">
            <Grid MaxWidth="384">
                <StackPanel>
                    <TextBlock Text="{Binding Title}" TextWrapping="NoWrap"/>
                    <TextBlock Text="{Binding Body}" TextWrapping="Wrap"/>
                </StackPanel>
            </Grid>
        </sw:HierarchicalDataTemplate>
	</UserControl.Resources>

	<Grid x:Name="LayoutRoot">
		<Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
			<RowDefinition/>
			<RowDefinition Height="Auto"/>
		</Grid.RowDefinitions>
        <CheckBox Content="Comments with Replies" IsChecked="{Binding ForceReplies, Mode=TwoWay, Source={StaticResource CommunityRecentCommentsDS}}"/>
        <controls:TreeView Grid.Row="1" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" ItemsSource="{Binding Mode=OneWay, Path=Results, Source={StaticResource CommunityRecentCommentsDS}}" Margin="2,2,2,2" ItemTemplate="{StaticResource CommentTemplate}">
            
        </controls:TreeView>
		<TextBlock HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Text="{Binding Mode=OneWay, Path=Copyright, Source={StaticResource CommunityRecentCommentsDS}}" TextWrapping="Wrap" Grid.Row="2" Margin="2,2,2,2"/>
	</Grid>
</UserControl>